#include <cstdlib>
#include <iostream>

#ifdef _MSC_VER
#pragma data_seg("MyShared")
#pragma comment(linker, "/Section:MyShared,RWS")
long g_count = 0;
#pragma data_seg()
#endif // _MSC_VER

#ifdef __MINGW32__
//long __attribute__((section ("MySHARED"), shared)) g_count = 0; 
//long g_count __attribute__((section ("MySHARED"), shared)) = 0; 
__attribute__((section ("MySHARED"), shared)) long g_count= 0; 
#endif //__MINGW32__

int main()
{
    g_count++;
    std::cout<<"g_count: "<<g_count<<std::endl;

    system("pause");
    return 0;
}
